﻿using GeneralDashboard.ViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GeneralDashboard.Pages
{
    /// <summary>
    /// DataSourcePage.xaml 的交互逻辑
    /// </summary>
    public partial class DataSourcePage : Page
    {
        public ObservableCollection<DataSourceViewModel> DataFrameFormat
        {
            get { return (ObservableCollection<DataSourceViewModel>)GetValue(DataFrameFormatProperty); }
            set { SetValue(DataFrameFormatProperty, value); }
        }

        // Using a DependencyProperty as the backing store for observableCollection.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty DataFrameFormatProperty =
            DependencyProperty.Register(nameof(DataFrameFormat), typeof(ObservableCollection<DataSourceViewModel>), typeof(DataSourcePage), new PropertyMetadata(null));

        public DataSourcePage()
        {
            InitializeComponent();
            DataContext = this;
            List<DataSourceViewModel> dataFrame = new List<DataSourceViewModel>
            {
                new DataSourceViewModel{ DataType = typeof(string), Title = "状态信息"},
                new DataSourceViewModel{ DataType = typeof(ulong), Title = "连接时间"},
                new DataSourceViewModel{ DataType = typeof(float), Title = "经度"},
                new DataSourceViewModel{ DataType = typeof(float), Title = "纬度"},
                new DataSourceViewModel{ DataType = typeof(double), Title = "前向加速度"},
                new DataSourceViewModel{ DataType = typeof(double), Title = "侧偏角"},
                new DataSourceViewModel{ DataType = typeof(double), Title = "俯仰角"},
                new DataSourceViewModel{ DataType = typeof(float), Title = "X速度分量"},
                new DataSourceViewModel{ DataType = typeof(float), Title = "Y速度分量"},
                new DataSourceViewModel{ DataType = typeof(float), Title = "Z速度分量"},
                new DataSourceViewModel{ DataType = typeof(bool), Title = "签入状态"},
                new DataSourceViewModel{ DataType = typeof(string), Title = "用户名"},
                new DataSourceViewModel{ DataType = typeof(sbyte), Title = "余量"},
                new DataSourceViewModel{ DataType = typeof(byte), Title = "灰度"},
                new DataSourceViewModel{ DataType = typeof(ulong), Title = "流量统计"},
                new DataSourceViewModel{ DataType = typeof(bool), Title = "硬件流控"},
                new DataSourceViewModel{ DataType = typeof(int), Title = "迭代次数"},
            };
            DataFrameFormat = new ObservableCollection<DataSourceViewModel>(dataFrame);
        }

        private void GridView_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetData(typeof(DataSourceViewModel)) is DataSourceViewModel unit)
            {
                MessageBox.Show(unit.Title);
            }
        }
    }
}
